﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace QuanLyKhachSan
{
    public partial class frmManHinhChinh : Form
    {
        frmDangNhap frmdn;
        NhanVienDTO nvdto;
        public frmManHinhChinh()
        {
            InitializeComponent();
        }

        private void frmManHinhChinh_Load(object sender, EventArgs e)
        {
            frmdn = new frmDangNhap();
            frmdn.frmmh = this;
            frmdn.ShowDialog();
            if (frmdn.nddto != null)
            {
                NhanVienBUS nvbus = new NhanVienBUS();
                nvdto = nvbus.LayNhanVienByMaNhanVien(frmdn.nddto.MaNhanVien);
                if (nvdto.ChucVu == "admin")
                {
                    //man hinh admin
                }
                else if (nvdto.ChucVu == "Quản lý")
                {
                    //man hinh quan ly
                }
                else
                {
                    //man hinh nhan vien
                }
                lblNguoiDung.Text = "xin chào "+nvdto.ChucVu+" : "+ nvdto.TenNhanVien;
            }
            else
            {
                Application.Exit();
            }
        }

        private void tlstrpmnuitemDangXuat_Click(object sender, EventArgs e)
        {
            DialogResult dlg = MessageBox.Show("Bạn thực sự muốn đăng xuất !", "Quản Lý Khách Sạn", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dlg == DialogResult.Yes)
            {
                nvdto = null;
                frmManHinhChinh_Load(sender, e);
            }
        }

        private void tlstrpmnuitemDoiMatKhau_Click(object sender, EventArgs e)
        {
            frmDoiMatKhau frmdmk = new frmDoiMatKhau();
            frmdmk.tendn = frmdn.nddto.TenDangNhap;
            frmdmk.ShowDialog();
        }

        private void tlstrpmnuitemThoat_Click(object sender, EventArgs e)
        {
            DialogResult dlg = MessageBox.Show("Bạn thực sự muốn thoát ?", "Quản Lý Khách Sạn", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dlg == DialogResult.Yes)
                Application.Exit();
        }

        private void tlstrpmnuitemPhong_Click(object sender, EventArgs e)
        {
            frmQuanLyPhong frmqlp = new frmQuanLyPhong();
            frmqlp.ShowDialog();
        }

        private void tlstrpmnuitemDichVu_Click(object sender, EventArgs e)
        {
            frmQuanLyDichVu frmqldv = new frmQuanLyDichVu();
            frmqldv.ShowDialog();
        }

        private void tlstrpmnuitemNhanVien_Click(object sender, EventArgs e)
        {
            frmQuanLyNhanVien frmqlnv = new frmQuanLyNhanVien();
            frmqlnv.ShowDialog();
        }

        private void tlstrpmnuitemVatTu_Click(object sender, EventArgs e)
        {
            frmQuanLyVatTu frmqlvt = new frmQuanLyVatTu();
            frmqlvt.ShowDialog();
        }
    }
}
